package com.lm.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理类
 * @author 只有影子
 */
@RestControllerAdvice
public class ExceptionHandle {
  @ExceptionHandler(Exception.class)
  @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
  public String sendErrorResponseSystem(Exception e) {
    // 这里只是模拟返回值，实际项目中一般都是返回封装好的统一返回类
    return e.getMessage();
  }
}
